Skip to content

test(renderer): pin the {{var}} injection-safety charset so a loosening can't slip in (#4)#126

Merged
ruvnet merged 1 commit into
mainfrom
test/renderer-injection-safety-regex
Jul 7, 2026
Merged

test(renderer): pin the {{var}} injection-safety charset so a loosening can't slip in (#4)#126
ruvnet merged 1 commit into
mainfrom
test/renderer-injection-safety-regex

Conversation

@ruvnet

@ruvnet ruvnet commented Jul 7, 2026

Copy link
Copy Markdown
Owner

What / why

Closes a mutation-surfaced test gap from the AQE beta feedback (#4). render() / extractVarReferences use a deliberately strict var-name charset — [a-zA-Z_][a-zA-Z0-9_]* — so a template can't reference dotted / hyphenated / leading-digit keys ({{a.b}}, {{../x}}, prototype-walking or path-like names). Mutation testing showed the regex can be loosened to admit ./-/leading-digit and every existing test still passes — the tests only cover valid names, whitespace, coercion, and malformed braces, never the boundary.

Change (test-only)

  • render() leaves {{foo.bar}} / {{foo-bar}} / {{1foo}} / {{a b}} literal (not interpolated), even when a matching key is present in vars, and reports them as un-matched (not unresolved).
  • extractVarReferences('{{a.b}} {{c-d}} {{1e}}') === [].

Mutation-kill verified

Loosening the charset to [a-zA-Z0-9_.-]+ makes both new tests fail; they pass on the real code. (Verified locally, then reverted.)

Tests

Full create-agent-harness suite 383/383; tsc clean. No behaviour change.

🤖 Generated with claude-flow

…ng can't slip in (#4)

Beta feedback #4 (mutation finding): render()/extractVarReferences use a deliberately strict var-name
charset — /\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g — so a template can't reference dotted/hyphenated/
leading-digit keys (`{{a.b}}`, `{{../x}}`, prototype-walking or path-like names). Mutation testing showed
the regex can be loosened to admit `.`/`-`/leading-digit and every existing test still passes, because
none pins the boundary — they only cover valid names, whitespace, coercion, and malformed braces.

Adds two mutation-killing tests:
- render() leaves `{{foo.bar}}` / `{{foo-bar}}` / `{{1foo}}` / `{{a b}}` LITERAL (not interpolated),
  even when a matching key is present in vars, and reports them as un-matched (not unresolved).
- extractVarReferences('{{a.b}} {{c-d}} {{1e}}') === [].

Verified: both FAIL when the charset is loosened to `[a-zA-Z0-9_.-]+`, and PASS on the real code.

Test-only; no behaviour change. Full create-agent-harness suite 383/383; tsc clean.

Co-Authored-By: claude-flow <ruv@ruv.net>
@ruvnet ruvnet merged commit 83ae846 into main Jul 7, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant